package com.bifrost.entity;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the PRODUCT_BRAND database table.
 */
@Entity
@Table(name = "PRODUCT_BRAND" , indexes = {@Index(name = "BRAND_LOGO_INDEX"  , columnList = "BRAND_LOGO")})
@NamedQuery(name = "ProductBrand.findAll", query = "SELECT p FROM ProductBrand p")
public class ProductBrand implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PRODUCT_BRAND_ID", unique = true, nullable = false)
    private Long productBrandId;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "BRAND_LOGO" ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT) , unique = true)
    private Media brandLogo;

    @Column(name = "BRAND_NAME", nullable = false, length = 100)
    private String brandName;

    @Column(name = "BRAND_CODE", length = 100)
    private String brandCode;

    @Column(name = "BRAND_OWNER")
    private String brandOwner;

    @Column(name = "BRAND_ORIGIN")
    private String brandOrigin;


    @Column(name = "BRAND_STYLE")
    private String brandStyle;

    @Column(name = "CANONICAL_URL", length = 255)
    private String canonicalUrl;

    @Lob
    @Column(name = "DESCRIPTION")
    private String description;

    @Column(name = "IS_ARCHIVED")
    private Boolean isArchived;

    @Column(name = "SORT_ORDER")
    private Integer sortOrder = 1;

    @Column(name = "UPDATED_BY", length = 64)
    private String updatedBy;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "UPDATED_TIMESTAMP")
    private Date updatedTimestamp;

    //bi-directional many-to-one association to Product
    @OneToMany(mappedBy = "productBrand")
    @org.hibernate.annotations.ForeignKey(name = "none")
    private List<Product> products;

    //bi-directional many-to-one association to MerchantStore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "MERCHANT_ID" ,foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private MerchantStore merchantStore;

    public ProductBrand() {
    }

    public Long getProductBrandId() {
        return this.productBrandId;
    }

    public void setProductBrandId(Long productBrandId) {
        this.productBrandId = productBrandId;
    }

    public Media getBrandLogo() {
        return this.brandLogo;
    }

    public void setBrandLogo(Media brandLogo) {
        this.brandLogo = brandLogo;
    }

    public String getBrandName() {
        return this.brandName;
    }

    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }

    public String getBrandCode() {
        return brandCode;
    }

    public void setBrandCode(String brandCode) {
        this.brandCode = brandCode;
    }

    public String getBrandOwner() {
        return brandOwner;
    }

    public void setBrandOwner(String brandOwner) {
        this.brandOwner = brandOwner;
    }

    public String getBrandOrigin() {
        return brandOrigin;
    }

    public void setBrandOrigin(String brandOrigin) {
        this.brandOrigin = brandOrigin;
    }

    public String getBrandStyle() {
        return brandStyle;
    }

    public void setBrandStyle(String brandStyle) {
        this.brandStyle = brandStyle;
    }

    public String getCanonicalUrl() {
        return this.canonicalUrl;
    }

    public void setCanonicalUrl(String canonicalUrl) {
        this.canonicalUrl = canonicalUrl;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean isArchived() {
        return this.isArchived;
    }

    public void setArchived(Boolean isArchived) {
        this.isArchived = isArchived;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }

    public String getUpdatedBy() {
        return this.updatedBy;
    }

    public void setUpdatedBy(String updatedBy) {
        this.updatedBy = updatedBy;
    }

    public Date getUpdatedTimestamp() {
        return this.updatedTimestamp;
    }

    public void setUpdatedTimestamp(Date updatedTimestamp) {
        this.updatedTimestamp = updatedTimestamp;
    }

    public List<Product> getProducts() {
        return this.products;
    }

    public void setProducts(List<Product> products) {
        this.products = products;
    }

    public Product addProduct(Product product) {
        getProducts().add(product);
        product.setProductBrand(this);

        return product;
    }

    public Product removeProduct(Product product) {
        getProducts().remove(product);
        product.setProductBrand(null);

        return product;
    }

    public MerchantStore getMerchantStore() {
        return this.merchantStore;
    }

    public void setMerchantStore(MerchantStore merchantStore) {
        this.merchantStore = merchantStore;
    }

}